/*************************************************************************
	> File Name: abby.c
	> Author: Angel Criss
	> Mail: abbytsing@gmail.com 
	> Created Time: 四  7/10 14:03:11 2014
 ************************************************************************/

#include "head.h"
#include "err.h"
int main(int argc,char *argv[])
{
    pid_t child;
    struct sigaction act;
    sigset_t block;
    void dealing(int);

    sigemptyset(&act.sa_mask);
    act.sa_flags=SA_RESTART;
    act.sa_handler=dealing;
    sigaddset(&act.sa_mask,SIGQUIT);
    sigaddset(&act.sa_mask,SIGINT);
    sigaction(SIGQUIT,&act,NULL);
    sigaction(SIGINT,&act,NULL);
    sigaction(SIGCHLD,&act,NULL);

    sigprocmask(SIG_BLOCK,&block,NULL);

    switch(child=fork())
    {
        case -1:
            err("fork");
        case 0:
            printf("this is in child precoss PID: %d",getpid());
            sleep(3);
            dealing(getpid());
            if(!errno)
            {
                printf("run dealing 1 once");
            }
            sleep(10);
            _exit(EXIT_SUCCESS);
        default:
            break;
    }
    for(;;)
        pause();
}
